Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix string conversion of Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome #4243

Merged
merged 7 commits into from
Jan 4, 2023

Conversation

MarcoRossignoli
Copy link
Contributor

@MarcoRossignoli MarcoRossignoli commented Jan 3, 2023

By design we cannot have a "correct" value from a string conversion from enum for the same underlying value.
The behavior changed since 7.0 and now the runtime is returning Min and not Error

fixed #4227

@MarcoRossignoli MarcoRossignoli changed the title Fix string conversion or Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome Fix string conversion or Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome Jan 3, 2023
@MarcoRossignoli MarcoRossignoli changed the title Fix string conversion or Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome Fix string conversion of Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome Jan 3, 2023
@MarcoRossignoli MarcoRossignoli changed the title Fix string conversion of Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome [BREAKING CHANGE]Fix string conversion of Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome Jan 3, 2023
@MarcoRossignoli
Copy link
Contributor Author

MarcoRossignoli commented Jan 3, 2023

using System.ComponentModel;

TestOutcome value = TestOutcome.Error;
Type valueType = value.GetType();
TypeConverter convert = TypeDescriptor.GetConverter(valueType);
var valueToSave = convert.ConvertToInvariantString(value);
Console.WriteLine(valueToSave);

internal enum TestOutcome
{
    /// <summary>
    /// There was a system error while we were trying to execute a test.
    /// </summary>
    Error,

    /// <summary>
    /// Test was executed, but there were issues.
    /// Issues may involve exceptions or failed assertions.
    /// </summary>
    Failed,

    /// <summary>
    /// The test timed out
    /// </summary>
    Timeout,

    /// <summary>
    /// Test was aborted.
    /// This was not caused by a user gesture, but rather by a framework decision.
    /// </summary>
    Aborted,

    /// <summary>
    /// Test has completed, but we can't say if it passed or failed.
    /// May be used for aborted tests...
    /// </summary>
    Inconclusive,

    /// <summary>
    /// Test was executed w/o any issues, but run was aborted.
    /// </summary>
    PassedButRunAborted,

    /// <summary>
    /// Test had it chance for been executed but was not, as ITestElement.IsRunnable == false.
    /// </summary>
    NotRunnable,

    /// <summary>
    /// Test was not executed.
    /// This was caused by a user gesture - e.g. user hit stop button.
    /// </summary>
    NotExecuted,

    /// <summary>
    /// Test run was disconnected before it finished running.
    /// </summary>
    Disconnected,

    /// <summary>
    /// To be used by Run level results.
    /// This is not a failure.
    /// </summary>
    Warning,

    /// <summary>
    /// Test was executed w/o any issues.
    /// </summary>
    Passed,

    /// <summary>
    /// Test has completed, but there is no qualitative measure of completeness.
    /// </summary>
    Completed,

    /// <summary>
    /// Test is currently executing.
    /// </summary>
    InProgress,

    /// <summary>
    /// Test is in the execution queue, was not started yet.
    /// </summary>
    Pending,

    /// <summary>
    /// The min value of this enum
    /// </summary>
    Min = Error,

    /// <summary>
    /// The max value of this enum
    /// </summary>
    Max = Pending
}

net6.0 output Error
net7.0 output Min

Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming this isn't tested as we didn't get any failure. Could we add a test?

MarcoRossignoli and others added 6 commits January 4, 2023 12:29
…stOutcome.cs

Co-authored-by: Amaury Levé <amaury.leve@gmail.com>
…stOutcome.cs

Co-authored-by: Amaury Levé <amaury.leve@gmail.com>
…stOutcome.cs

Co-authored-by: Amaury Levé <amaury.leve@gmail.com>
@MarcoRossignoli MarcoRossignoli changed the title [BREAKING CHANGE]Fix string conversion of Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome Fix string conversion of Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome Jan 4, 2023
@MarcoRossignoli
Copy link
Contributor Author

MarcoRossignoli commented Jan 4, 2023

We found out that the enum is internal and Min/Max are not used and we have only 1 friend, the unit test project, should be safe remove.

@MarcoRossignoli MarcoRossignoli enabled auto-merge (squash) January 4, 2023 14:06
@MarcoRossignoli MarcoRossignoli merged commit a6db0cb into microsoft:main Jan 4, 2023
@MarcoRossignoli MarcoRossignoli deleted the fixtrx branch January 4, 2023 15:01
MarcoRossignoli added a commit to MarcoRossignoli/vstest that referenced this pull request Jan 5, 2023
….ObjectMode.TestOutcome` (microsoft#4243)

Fix string conversion of `Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome`
MarcoRossignoli added a commit that referenced this pull request Jan 5, 2023
….ObjectMode.TestOutcome` (#4243) (#4246)

Fix string conversion of `Microsoft.TestPlatform.Extensions.TrxLogger.ObjectMode.TestOutcome`
MarcoRossignoli pushed a commit to MarcoRossignoli/vstest that referenced this pull request Jan 6, 2023
MarcoRossignoli added a commit that referenced this pull request Jan 6, 2023
…rxLogger.ObjectMode.TestOutcome` (#4243) (#4246)" (#4247)

This reverts commit 6b7b112.

Co-authored-by: Marco Rossignoli <mrossignol@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TRX writer emits Min as outcome instead of Error in .NET 7.0
2 participants